repo: Add APIs for devino optimization between checkout -> commit
authorColin Walters <walters@verbum.org>
Tue, 5 Jan 2016 14:13:54 +0000 (09:13 -0500)
committerColin Walters <walters@verbum.org>
Thu, 7 Jan 2016 19:19:12 +0000 (14:19 -0500)
commit5929ce9e0e04e5dea0f654515629bfd2dd08f9df
tree0bfa650bf520fdbd730c0abbec554c168937a10f
parent21fbc16bc35869b547ec4f2bdbef59af9ce0ccc9
repo: Add APIs for devino optimization between checkout -> commit

A fast way to generate new OSTree content using an existing
tree is to checkout (as hard links), add/replace files, then
call `ostree_repo_scan_hardlinks()`, then commit.

But `ostree_repo_scan_hardlinks()` scans the entire repo, which
can be slow if you have a lot of content.

All we really need is a mapping of (device,inode) -> checksum
just for the objects we checked out, then use that mapping
for commits.

This patch adds API so that callers can create a mapping via
`ostree_repo_devino_cache_new()`, then pass it to
`ostree_repo_checkout_tree_at()` which will populate it, and then
`ostree_repo_write_directory_to_mtree()` can consume it.

I plan to use this in rpm-ostree for package layering work.

Notes:
 - The old `ostree_repo_scan_hardlinks()` API still works.
 - I tweaked the cache to be a set with the checksum colocated with
   the key, to avoid a separate malloc block per entry.

https://github.com/GNOME/ostree/pull/167
doc/ostree-sections.txt
src/libostree/ostree-repo-checkout.c
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.h
src/libostree/ostree-types.h